package com.example.projectgamefinal1;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class Category extends Activity {

	private Spinner spinner1, spinner2, spinner3;
	private Button btnSubmit1;
	private Button btnSubmit2, btnSubmit3;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		/*super.onCreate(savedInstanceState);

		Intent intent = getIntent();
		String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
		int no = intent.getIntExtra(MainActivity.EXTRA_MESSAGE, 0);
		ImageView cimg = (ImageView) findViewById(R.id.imageView1);

		switch (no) {
		case 1:
			TextView textView = new TextView(this);
			textView.setTextSize(40);
			textView.setText(message);
			cimg.setImageResource(R.drawable.arkitektur);
			setContentView(R.layout.category);
			break;
		case 2:
			TextView textView1 = new TextView(this);
			textView1.setTextSize(40);
			textView1.setText(message);
			cimg.setImageResource(R.drawable.brugere_funktion);
			setContentView(R.layout.category);
			break;
		case 3:
			setContentView(R.layout.energidesign_page);
			break;
		case 4:
			setContentView(R.layout.industialisering);
			break;
		case 5:
			setContentView(R.layout.okonomi_page);
			break;
		case 6:
			setContentView(R.layout.tekniske_install_page);
			break;
		case 7:
			setContentView(R.layout.stedet_page);
			break;
		case 8:
			setContentView(R.layout.stabilitet_page);
			break;
		}
		 */
		setContentView(R.layout.category);
		addListenerOnButton();
		addListenerOnSpinnerItemSelection();
		// Show the Up button in the action bar.
		//setupActionBar();
	}

	public void addListenerOnSpinnerItemSelection() {
		spinner1 = (Spinner) findViewById(R.id.redBricksList);
		spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());
		spinner2 = (Spinner) findViewById(R.id.yellowBricksList);
		spinner2.setOnItemSelectedListener(new CustomOnItemSelectedListener());
		spinner3 = (Spinner) findViewById(R.id.greenBricksList);
		spinner3.setOnItemSelectedListener(new CustomOnItemSelectedListener());
	}

	// get the selected dropdown list value
	public void addListenerOnButton() {

		spinner1 = (Spinner) findViewById(R.id.redBricksList);
		spinner2 = (Spinner) findViewById(R.id.yellowBricksList);
		spinner3 = (Spinner) findViewById(R.id.greenBricksList);
		btnSubmit1 = (Button) findViewById(R.id.addBrickBtn1);
		btnSubmit1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Toast.makeText(
						Category.this,
						"OnClickListener : " + "\nSpinner 1 : "
								+ String.valueOf(spinner1.getSelectedItem()),
						Toast.LENGTH_SHORT).show();				
			}

		});
		btnSubmit2 = (Button) findViewById(R.id.addBrickBtn2);
		btnSubmit2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Toast.makeText(
						Category.this,
						"OnClickListener : " + "\nSpinner 2 : "
								+ String.valueOf(spinner2.getSelectedItem()),
						Toast.LENGTH_SHORT).show();				
			}

		});
		btnSubmit3 = (Button) findViewById(R.id.addBrickBtn3);
		btnSubmit3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Toast.makeText(
						Category.this,
						"OnClickListener : " + "\nSpinner 1 : "
								+ String.valueOf(spinner3.getSelectedItem()),
						Toast.LENGTH_SHORT).show();				
			}

		});
	}

	/**
	 * Set up the {@link android.app.ActionBar}, if the API is available.
	 */
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void setupActionBar() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			getActionBar().setDisplayHomeAsUpEnabled(true);
		}
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
